// void, Obj This

Unit newunit;
Barrack this;
point ptExit;
str r;

this = This.AsBuilding();

while(.settlement.IsFull)
	Sleep(500);
	
.Progress();
while(.settlement.IsFull)
	Sleep(500);

ptExit = .GetExitPoint(.settlement.GetCentralBuilding.pos, false);

if(ptExit.x==-1 && ptExit.y==-1){
	Sleep(rand(100)+100);
	newunit = Place(cmdparam, Point(0,0), this.player);

} else {
	Sleep(rand(100)+100);
	newunit = Place(cmdparam, ptExit, this.player);
	if(newunit.IsValid)
		newunit.SetCommand("advanceenter", .settlement.GetCentralBuilding);
}
if(newunit.IsValid){
	newunit.AddItem("tax_collector_stop");
	//newunit.SetLevel(level);
}

